<?php
class form extends CI_Model {
	var $form = '';
	var $name = '';
	var $type = '';
	var $value = '';
	var $valuex = '';
	var $forms = array('input', 'password', 'kong', 'mkdate', 'textarea', 'select', 'gys', 'identity','identitys', 'classd', 'hlxm', 'pics', 'pic', 'filex', 'radio', 'checkbox', 'kindeditor', 'bill', 'shop', 'shopd', 'shopx', 'staffd', 'frfx', 'cddh');
	function doform($form, $name, $type = '', $value = '', $valuex = '', $xml = FALSE) {
		$this -> form = $form;
		$this -> name = $name;
		$this -> type = $type;
		$this -> value = $value;
		$this -> valuex = $valuex;
		$this -> xml = $xml;
		if (in_array($this -> form, $this -> forms)) {
			$ls = $this -> type ? $this -> form . '_' . $this -> type : $this -> form;
			return $this -> $ls();
		} else {
			return '表单不存在。';
		}
	}

	function input() {
		$this -> value = $this -> value ? $this -> value : $this -> valuex;
		return '<input class="inputx" type="text" name="' . $this -> name . '" value="' . $this -> value . '">';
	}

	function input_in() {
		$this -> value = $this -> value != '' ? $this -> value : $this -> valuex;
		return $this -> value;
	}

	function input_out() {
		$this -> value = $this -> value != '' ? $this -> value : $this -> valuex;
		return $this -> value;
	}

	function frfx() {
		$ls = substr($this -> name, 0, -1);
		$da['model'] = $this -> infox -> get_model($ls, 'table_name');
		$da['value'] = $this -> value;
		$da['valuex'] = $this -> valuex;
		$info = '<input class="inputx" type="hidden" name="' . $this -> name . '" value="' . $this -> value . '">';
		$info .= $this -> load -> view('common/frfx_bill', $da, true);
		return $info;
	}

	function frfx_in() {
		$this -> value = $this -> value != '' ? $this -> value : $this -> valuex;
		return $this -> value;
	}

	function frfx_out() {
		$this -> value = $this -> value != '' ? $this -> value : $this -> valuex;
		return $this -> value;
	}

	function password() {
		return '<input class="inputx" type="password" name="' . $this -> name . '" value="***">';
	}

	function password_in() {
		if ($this -> value != '***' && $this -> value != '') {
			$this -> value = md5($this -> value);
		} else {
			$this -> value = '';
		}
		return $this -> value;
	}

	function password_out() {

		return '***';
	}

	function kong() {
		return '不提供检索';
	}

	function kong_in() {

		return '';
	}

	function kong_out() {

		return '';
	}

	function mkdate() {
		if (is_numeric($this -> value)) {
			$this -> mkdate_out();
		} else {
			$this -> value = date('Y-m-d');
		}
		$info = '<input onclick="HS_setDate(this)" readonly class="inputx" id="mkdate" type="text" name="' . $this -> name . '" value="' . $this -> value . '">';
		if ($this -> name == 'birthday') {
			$info .= '<span style="cursor: pointer;" onclick="sfzhq($(this))">  身份证获取</span>';
		}
		return $info;
	}

	function mkdate_in() {
		return strtotime($this -> value);
	}

	function mkdate_out() {
		if (is_numeric($this -> value) && $this -> value > 0) {
			$this -> value = date('Y-m-d', $this -> value);
		} elseif (!$this -> value) {
			$this -> value = '未填写';
		}
		return $this -> value;
	}

	function textarea() {
		$info = '<textarea class="inputx" style="width:220px;height:100px;" name="' . $this -> name . '">' . $this -> value . '</textarea><br><span style="cursor: pointer;" onclick="crdata($(this))">插入时间</span><span class="hd">' . date('Y-m-d H:i') . '</span>';
		return $info;
	}

	function textarea_in() {

		return $this -> value;
	}

	function textarea_out() {

		return $this -> value;
	}

	function bill() {
		$ls = substr($this -> name, 0, -1);
		$da['model'] = $this -> infox -> get_model($ls, 'table_name');
		$da['value'] = $this -> value;
		$da['valuex'] = $this -> valuex;
		$info = '<input class="inputx" type="hidden" name="' . $this -> name . '" value="' . $this -> value . '">';
		$info .= $this -> load -> view('common/form_bill', $da, true);
		return $info;
	}

	function bill_in() {
		return $this -> value;
	}

	function bill_out() {
		$ls = substr($this -> name, 0, -1);
		$info = '';
		$da['model'] = $this -> infox -> get_model($ls, 'table_name');
		$da['value'] = $this -> value;
		$da['valuex'] = $this -> valuex;
		$da['pd'] = 2;
		$info .= $this -> load -> view('common/form_bill_out', $da, true);
		if ($this -> xml) {
			$info = '内容不提供导出。';
		}
		return $info;
	}

	function out_value($table = 'contactperson', $id = 1) {
		$names = array('name', 'title', $table . '_name', $table . '_title');
		$q = $this -> db -> get_where('ci', array('table_name' => $table));
		$ls = $q -> row_array(0);
		$file_info = unserialize($ls['file_info']);
		$name = '';
		$this -> db -> where_in($ls['table_name'] . '_id', explode(',', $id));
		$q = $this -> db -> get_where($table);
		if ($q -> num_rows() > 0) {
			$title = '';

			$info = $q -> row_array(0);
			foreach ($names as $v) {
				if (key_exists($v, $info)) {
					$name = $info[$v];
				}
			}
			foreach ($file_info as $v) {
				if ($v['field_show'] == 1) {
					$ls = $v['field_add'] . '_out';
					$this -> value = $info[$v['field_name_en']];
					$this -> valuex = $v['field_value'];
					$title .= $v['field_name'] . ':' . $this -> $ls() . '<br>';
				}
			}
			$return = '<div class="teshu" title="' . $title . '">' . $name . '</div>';

		} else {
			$return = '';
		}

		return $return;
	}

	//导出
	function export_hidden($id, $table = '') {
		if ($id && $table) {
			$table = substr($table, 0, -1);
			$return = '';
			$q = $this -> db -> get_where('ci', array('table_name' => $table));
			$ls = $q -> row_array(0);
			$file_info = unserialize($ls['file_info']);

			$q = $this -> db -> get_where($table, array($ls['table_name'] . '_id' => $id));
			$info = $q -> row_array(0);
			foreach ($file_info as $v) {
				if ($v['field_show'] == 1) {
					$ls = $v['field_add'] . '_out';
					$this -> value = $info[$v['field_name_en']];
					$this -> valuex = $v['field_value'];
					$return .= $v['field_name'] . ':' . $this -> $ls() . ' -- ';
				}
			}
		} else {
			$return = '';
		}
		return $return;
	}

	function select() {
		$info = '<select class="inputx form-control" name="' . $this -> name . '">';
		if ($this -> valuex) {
			$ls = explode('-', $this -> valuex);
			foreach ($ls as $v) {
				$lsx = explode('|', $v);
				if ($this -> value == $lsx[1]) {
					$info .= '<option selected value="' . $lsx[1] . '">' . $lsx[0] . '</option>';
				} else {
					$info .= '<option value="' . $lsx[1] . '">' . $lsx[0] . '</option>';
				}
			}
		}
		$info .= '</select>';
		return $info;
	}

	function select_out() {
		$info = '';
		if ($this -> valuex) {
			$ls = explode('-', $this -> valuex);
			foreach ($ls as $v) {
				$lsx = explode('|', $v);
				if ($this -> value == $lsx[1]) {
					$info = $lsx[0];
				}
			}
		}
		return $info;
	}

	function select_in() {
		$info = '';
		if ($this -> valuex) {
			if (is_numeric($this -> value)) {
				$info = $this -> value;
			} else {
				$ls = explode('-', $this -> valuex);
				foreach ($ls as $v) {
					$lsx = explode('|', $v);
					if ($this -> value == $lsx[0]) {
						$info = $lsx[1];
					}
				}
			}
		}
		return $info;
	}

	//身份选择
	function identity() {
		$info = '<select data-rel="chosen" class="inputx form-control" name="' . $this -> name . '">';
		$this -> db -> select('identity_id,name');
		$q = $this -> db -> get('identity');
		foreach ($q->result_array() as $v) {
			if ($this -> value == $v['identity_id']) {
				$info .= '<option selected value="' . $v['name'] . '">' . $v['name'] . '</option>';
			} else {
				$info .= '<option value="' . $v['name'] . '">' . $v['name'] . '</option>';
			}
		}
		$info .= '</select>';
		return $info;
	}

	function identity_in() {
		$info = $this -> value;
		if (!is_numeric($this -> value) && $this -> value) {
			$this -> db -> select('identity_id,name');
			$q = $this -> db -> get_where('identity', array('name' => $this -> value));
			if ($q -> num_rows() > 0) {
				$ls = $q -> row_array(0);
				$info = $ls['identity_id'];
			}
		}
		return $info;
	}

	function identity_out() {
		$info = $this -> value;
		if (is_numeric($this -> value) && $this -> value) {
			$this -> db -> select('identity_id,name');
			$q = $this -> db -> get_where('identity', array('identity_id' => $this -> value));
			if ($q -> num_rows() > 0) {
				$ls = $q -> row_array(0);
				$info = $ls['name'];
			}
		}
		return $info;
	}

	function gys() {
		$info = '<select data-rel="chosen" class="inputx form-control" name="' . $this -> name . '">';
		$this -> db -> select('gys_id,name');
		$q = $this -> db -> get('gys');
		foreach ($q->result_array() as $v) {
			if ($this -> value == $v['gys_id']) {
				$info .= '<option selected value="' . $v['name'] . '">' . $v['name'] . '</option>';
			} else {
				$info .= '<option value="' . $v['name'] . '">' . $v['name'] . '</option>';
			}
		}
		$info .= '</select>';
		return $info;
	}

	function gys_in() {
		$info = $this -> value;
		if (!is_numeric($this -> value) && $this -> value) {
			$this -> db -> select('gys_id,name');
			$q = $this -> db -> get_where('gys', array('name' => $this -> value));
			if ($q -> num_rows() > 0) {
				$ls = $q -> row_array(0);
				$info = $ls['gys_id'];
			}
		}
		return $info;
	}

	function gys_out() {
		$info = $this -> value;
		if (is_numeric($this -> value) && $this -> value) {
			$this -> db -> select('gys_id,name');
			$q = $this -> db -> get_where('gys', array('gys_id' => $this -> value));
			if ($q -> num_rows() > 0) {
				$ls = $q -> row_array(0);
				$info = $ls['name'];
			}
		}
		return $info;
	}

	//身份选择
	function classd() {
		$table = substr($this -> name, 0, -1);
		$ls = explode('-', $this -> value);
		$info = $this -> tiedai(0, $ls, '');
		$info .= '<input type="hidden" value="'.$this -> value.'" class="inputx" style="display:none;" name="' . $this -> name . '" />';
		return $info;
	}

	function tiedai($pid, $ls, $info) {
		$table = substr($this -> name, 0, -1);
		$id = $table . '_id';
		$this -> db -> select($id . ',name');
		$this -> db -> where('pid', $pid);
		$this->db->where('sf',$this->valuex);
		$this->db->where($table.'_del',1);
		//特殊处理分类
		if($table=='wx_anniu' && $this->valuex){
			$this->db->where('sf',$this->valuex);
		}
		if($table=='wx_anniu'){
			$this->db->where('shop_id',$this->session->userdata('shop_id'));
		}
		$q = $this -> db -> get($table);
		$pidx = $pid;
		if ($q -> num_rows() > 0) {
			$info .= '<select named="' . $table . '" class="classd form-control" style="width:150px;display: inline-block;" onchange="doclassd($(this))"><option idx="" value="">-请选择-</option>';
			foreach ($q->result_array() as $v) {
				if (in_array($v['name'], $ls)) {
					$info .= '<option idx="' . $v[$id] . '" selected value="' . $v['name'] . '">' . $v['name'] . '</option>';
					$pidx = $v[$id];
				} else {
					$info .= '<option idx="' . $v[$id] . '" value="' . $v['name'] . '">' . $v['name'] . '</option>';
				}
			}
			$info .= '</select>';
		}
		if ($pidx != $pid) {
			$info = $this -> tiedai($pidx, $ls, $info);
		}
		return $info;
	}

	function classd_in() {
		$info = $this -> value;
		return $info;
	}

	function classd_out() {
		$info = $this -> value;
		return $info;
	}

	function hlxm() {
		$this -> value = $this -> value ? $this -> value : $this -> valuex;
		$info = '<input class="inputx" type="hidden" name="' . $this -> name . '" value="' . $this -> value . '">';
		$info .= $this -> hlxm_out();
		$info .= '<br><input onclick="hlxm_th($(this))" class="btn btn-primary" type="button" value="添加行"> | ';
		$info .= '<input onclick="hlxm_tl($(this))" class="btn btn-primary" type="button" value="添加列">';
		return $info;
	}

	function hlxm_in() {
		$this -> value = $this -> value != '' ? $this -> value : $this -> valuex;
		return $this -> value;
	}

	function hlxm_out() {
		$this -> value = $this -> value != '' ? $this -> value : $this -> valuex;
		$info = '<table class="table table-bordered">';
		if ($this -> value) {
			$ls = explode('+++', $this -> value);
			foreach ($ls as $k => $v) {
				if (!empty($v[0])) {
					$info .= '<tr idx="">';
					$lss = explode('---', $v);
					foreach ($lss as $kk => $vv) {
						if ($k == 0) {
							$info .= '<th style="color:#000;" ondblclick="hlxm_td($(this))">';
						} else {
							$info .= '<td ondblclick="hlxm_td($(this))">';
						}
						$info .= $vv ? $vv : '&nbsp;&nbsp;&nbsp;';
						if ($k == 0) {
							$info .= '</th>';
						} else {
							$info .= '</td>';
						}
					}
					$info .= '</tr>';
				}
			}
		} else {
			$info .= '<tr idx="">
					<th style="color:#000;" ondblclick="hlxm_td($(this))">编码</th>
					<th style="color:#000;" ondblclick="hlxm_td($(this))">护理项目</th>
					<th style="color:#000;" ondblclick="hlxm_td($(this))">原价</th>
					<th style="color:#000;" ondblclick="hlxm_td($(this))">次数</th>
				  </tr>
					<tr class="hlxm_mb" idx="">
						<td ondblclick="hlxm_td($(this))"> </td>
						<td ondblclick="hlxm_td($(this))"> </td>
						<td ondblclick="hlxm_td($(this))"> </td>
						<td ondblclick="hlxm_td($(this))"> </td>
					</tr>';
		}

		$info .= '</table>';
		if ($this -> xml) {
			$info = '内容不提供导出。';
		}
		return $info;
	}

	function pics() {
		$info = '<input class="inputx" type="hidden" name="' . $this -> name . '" value="' . $this -> value . '">';
		$info .= '<input style="width:50px;margin-right: 20px;" type="text" class="numbx" type="text" value="1">';
		$info .= '<input type="button" class="btn"  style="margin-top: -5px;" value="添加" onclick="pic_add($(this))"><br><br>';

		$info .= '<p class="pic_mb hd"><span style="cursor:pointer;" onclick="pic_del($(this))">删除  - </span><input idx="" style="width: 100px;" class="fileToUpload" type="file" size="45" name="fileToUpload" class="input" onchange="upx($(this))">';
		$info .= '<span class="pic_show"></span>';
		$info .= '<img class="loading" src="/mex/lance/img/loading.gif" style="display:none;"> </p>';

		$info .= '<div class="pics">';
		if ($this -> value) {
			$this -> db -> where('upfile_del', 1);
			$this -> db -> where_in('upfile_id', explode(',', $this -> value));
			$q = $this -> db -> get('upfile');
			foreach ($q->result_array() as $v) {
				$info .= '<p idx="' . $v['upfile_id'] . '" title="' . $v['name'] . '"><span style="cursor:pointer;" onclick="pic_del($(this))">删除  - </span><input idx="" style="width: 100px;" class="fileToUpload" type="file" size="45" name="fileToUpload" class="input" onchange="upx($(this))">';
				$info .= '<span class="pic_show"><img class="thumbnail"  src="' . $this->infox->oss_dz($v['url'] . $v['file'] ). '"></span>';
				$info .= '<img class="loading" src="/adx/images/loading1.gif" style="display:none;"></p>';
			}
		}
		$info .= '</div>';
		return $info;
	}

	function pics_in() {
		$this -> value = $this -> value != '' ? $this -> value : $this -> valuex;
		return $this -> value;
	}

	function pics_out() {
		$info = '';
		if ($this -> value) {
			$this -> db -> where('upfile_del', 1);
			$this -> db -> where_in('upfile_id', explode(',', $this -> value));
			$q = $this -> db -> get('upfile');
			foreach ($q->result_array() as $v) {
				$info .= '<p idx="' . $v['upfile_id'] . '" title="' . $v['name'] . '">';
				$info .= '<img width="100"  src="' .$this->infox->oss_dz( $v['url'] . $v['file'] ). '">';
				$info .= '</p>';
			}
		}
		if ($this -> xml) {
			$info = '内容不提供导出。';
		}
		return $info;
	}

	function pic() {
		$info = '<input class="inputx" type="hidden" name="' . $this -> name . '" value="' . $this -> value . '">';
		$info .= '<img class="loading" src="/mex/lance/img/loading.gif" style="display:none;">';
		$info .= '<input  onchange="upxd($(this))" class="fileToUpload" type="file" size="45" name="fileToUpload" class="input">';
		if ($this -> value) {
			$info .= '<span class="showpic"><img style="width:150px;" class="thumbnail" src="' .$this->pub->oss_dz($this -> value) . '"></span>';
		} else {
			$info .= '<span class="showpic"></span>';
		}

		return $info;
	}

	function pic_in() {
		$this -> value = $this -> value != '' ? $this -> value : $this -> valuex;
		return $this -> value;
	}

	function pic_out() {
		$info = '';
		if ($this -> value) {
			$info = '<img width="100" src="' .$this->infox->oss_dz($this -> value) . '">';
		}
		if ($this -> xml) {
			$info = '内容不提供导出。';
		}
		return $info;
	}

	function filex() {
		$info = '<input class="inputx" type="hidden" name="' . $this -> name . '" value="' . $this -> value . '">';
		$info .= '<img class="loading" src="/adx/images/loading1.gif" style="display:none;">';
		$info .= '<input style="width: 100px;" class="fileToUpload" type="file" size="45" name="fileToUpload" class="input">';
		if ($this -> value) {
			$info .= '<input type="button" class="btn btn-primary" value="上传文件" onclick="upxd($(this))"><span class="showpic"><br><br><a title="点击下载" href="' .$this->infox->oss_dz($this -> value). '"><img src="/adx/images/filex.png"></a></span>';
		} else {
			$info .= '<input type="button" class="btn btn-primary" value="上传文件" onclick="upxd($(this))"><span class="showpic"></span>';
		}
		return $info;
	}

	function filex_in() {
		$this -> value = $this -> value != '' ? $this -> value : $this -> valuex;
		return $this -> value;
	}

	function filex_out() {
		$info = '';
		if ($this -> value) {
			$info = '<a title="点击下载" href="' . $this->infox->oss_dz($this -> value) . '"><img src="/adx/images/filex.png"></a>';
		}
		return $info;
	}

	function radio() {
		$name = random_string('unique');
		$info = '<input class="inputx" type="hidden" name="' . $this -> name . '" value="' . $this -> value . '">';
		if ($this -> valuex) {
			$ls = explode('-', $this -> valuex);
			foreach ($ls as $v) {
				$lsx = explode('|', $v);
				if ($this -> value == $lsx[1]) {
					$info .= '<input onclick="radiox($(this))" name="' . $name . '"  type="radio" checked value="' . $lsx[1] . '">' . $lsx[0] . '</input>';
				} else {
					$info .= '<input onclick="radiox($(this))" name="' . $name . '"  type="radio" value="' . $lsx[1] . '">' . $lsx[0] . '</input>';
				}
			}
		}
		return $info;
	}

	function radio_out() {
		$info = '';
		if ($this -> valuex && is_numeric($this -> value)) {
			$ls = explode('-', $this -> valuex);
			foreach ($ls as $v) {
				$lsx = explode('|', $v);
				if ($this -> value == $lsx[1]) {
					$info = $lsx[0];
				}
			}
		}
		return $info;
	}

	function radio_in() {
		$info = '';
		if ($this -> valuex) {
			if (is_numeric($this -> value)) {
				$info = $this -> value;
			} else {
				$ls = explode('-', $this -> valuex);
				foreach ($ls as $v) {
					$lsx = explode('|', $v);
					if ($this -> value == $lsx[0]) {
						$info = $lsx[1];
					}
				}
			}
		}
		return $info;
	}

	function checkbox() {
		$name = random_string('unique');
		$info = '<input class="inputx" type="hidden" name="' . $this -> name . '" value="' . $this -> value . '">';
		$value = explode('-', $this -> value);
		if ($this -> valuex) {
			$ls = explode('-', $this -> valuex);
			foreach ($ls as $v) {
				if (in_array($v, $value)) {
					$info .= '<input class="classd" onclick="checkboxx($(this))" name="' . $name . '"  type="checkbox" checked value="' . $v . '">' . $v . '</input>';
				} else {
					$info .= '<input class="classd" onclick="checkboxx($(this))" name="' . $name . '"  type="checkbox" value="' . $v . '">' . $v . '</input>';
				}
				$info .= '&nbsp;&nbsp;';
			}
		}
		return $info;
	}

	function checkbox_out() {
		return $this -> value ? $this -> value : '';
	}

	function checkbox_in() {
		return $this -> value ? $this -> value : '';
	}

	function identitys() {
		$name = random_string('unique');
		$info = '<input class="inputx" type="hidden" name="' . $this -> name . '" value="' . $this -> value . '">';
		$value = explode('-', $this -> value);
		$q=$this->db->get('identity');
		$ls = $q->result_array();
		foreach ($ls as $v) {
			if (in_array($v['name'], $value)) {
				$info .= '<input class="classd" onclick="checkboxx($(this))" name="' . $name . '"  type="checkbox" checked value="' . $v['name'] . '">' . $v['name'] . '</input>';
			} else {
				$info .= '<input class="classd" onclick="checkboxx($(this))" name="' . $name . '"  type="checkbox" value="' . $v['name'] . '">' . $v['name'] . '</input>';
			}
			$info .= '&nbsp;&nbsp;';
		}
		return $info;
	}

	function identitys_out() {
		return $this -> value ? $this -> value : '';
	}

	function identitys_in() {
		return $this -> value ? $this -> value : '';
	}

	function cddh() {
		$name = random_string('unique');
		$info = '<input class="inputx" type="hidden" name="' . $this -> name . '" value="' . $this -> value . '">';
		$value = explode('-', $this -> value);
		$ls = explode('-', $this -> valuex);
		$q = $this -> db -> get('cddh');
		foreach ($q->result_array() as $v) {
			if (in_array($v['name'], $value)) {
				$info .= '<input class="classd" onclick="checkboxx($(this))" name="' . $name . '"  type="checkbox" checked value="' . $v['name'] . '">' . $v['name'] . '</input>';
			} else {
				$info .= '<input class="classd" onclick="checkboxx($(this))" name="' . $name . '"  type="checkbox" value="' . $v['name'] . '">' . $v['name'] . '</input>';
			}
			$info .= '&nbsp;&nbsp;';
		}
		return $info;
	}

	function cddh_out() {
		return $this -> value ? $this -> value : '';
	}

	function cddh_in() {
		return $this -> value ? $this -> value : '';
	}

	function kindeditor() {
		$name = random_string('unique');
		$info = '<textarea  sf="k" bs="' . $name . '" class="inputx" style="width:300px;height:200px;display:none;" name="' . $this -> name . '">' . $this -> value . '</textarea>';
		return $info;
	}

	function kindeditor_in() {
		return $this -> value;
	}

	function kindeditor_out() {
		$this -> load -> helper('text');
		$info = ellipsize(strip_tags($this -> value), 50, 1);
		return $info;
	}

	function shop() {
		//获取店铺
		$this -> db -> select('shop_name');
		$q = $this -> db -> get('shop');
		$this -> value = $this -> value ? $this -> value : $this -> valuex;
		$ls = explode('-', $this -> value);
		$info = '<input class="inputx" type="hidden" name="' . $this -> name . '" value="' . $this -> value . '"><br>';
		foreach ($q->result_array() as $v) {
			if (in_array($v['shop_name'], $ls)) {
				$info .= '<input onclick="shopx($(this))" class="shopx" checked type="checkbox"  value="' . $v['shop_name'] . '">' . $v['shop_name'] . ' <br>';
			} else {
				$info .= '<input onclick="shopx($(this))" class="shopx" type="checkbox"  value="' . $v['shop_name'] . '">' . $v['shop_name'] . ' <br> ';
			}
		}
		return $info;
	}

	function shop_in() {
		$this -> value = $this -> value != '' ? $this -> value : $this -> valuex;
		return $this -> value;
	}

	function shop_out() {
		$this -> value = $this -> value != '' ? $this -> value : $this -> valuex;
		return $this -> value;
	}

	function shopd() {
		$this -> db -> select('shop_name,shop_id');
		$q = $this -> db -> get('shop');
		$this -> value = $this -> value ? $this -> value : $this -> valuex;
		$info = '<select class="inputx" name="' . $this -> name . '" value="' . $this -> value . '">';
		foreach ($q->result_array() as $v) {
			if ($v['shop_id'] == $this -> value or ($v['shop_id'] == $this -> session -> userdata('shop_id') && $this -> value == 0)) {
				$info .= '<option selected value="' . $v['shop_id'] . '">' . $v['shop_name'] . ' </option>';
			} else {
				$info .= '<option value="' . $v['shop_id'] . '">' . $v['shop_name'] . ' </option>';
			}
		}
		$info .= '</select>';
		return $info;
	}

	function shopd_in() {
		$this -> value = $this -> value != '' ? $this -> value : $this -> valuex;
		return $this -> value;
	}

	function shopd_out() {
		$info = '';
		if (is_numeric($this -> value)) {
			$this -> db -> select('shop_name');
			$q = $this -> db -> get_where('shop', array('shop_id' => $this -> value));
			if ($q -> num_rows() > 0) {
				$ls = $q -> row_array(0);
				$info = $ls['shop_name'];
			}
		}
		return $info;
	}

	function shopx() {
		$q = $this -> db -> get_where('staff', array('staff_id' => $this -> session -> userdata('mid')));
		$ls = $q -> row_array(0);
		if ($ls['shopd']) {
			$this -> db -> where_in('shop_name', explode('-', $ls['shopd']));
		} else {
			$this -> db -> where('shop_id', $this -> session -> userdata('shop_id'));
		}

		$this -> db -> select('shop_name,shop_id');
		$q = $this -> db -> get('shop');
		$this -> value = $this -> value ? $this -> value : $this -> valuex;
		$info = '<select class="inputx" name="' . $this -> name . '" value="' . $this -> value . '">';
		foreach ($q->result_array() as $v) {
			if ($v['shop_id'] == $this -> value) {
				$info .= '<option selected value="' . $v['shop_id'] . '">' . $v['shop_name'] . ' </option>';
			} elseif ($v['shop_id'] == $this -> session -> userdata('shop_id') && $this -> value == '') {
				$info .= '<option selected value="' . $v['shop_id'] . '">' . $v['shop_name'] . ' </option>';
			} else {
				$info .= '<option value="' . $v['shop_id'] . '">' . $v['shop_name'] . ' </option>';
			}
		}
		$info .= '</select>';
		return $info;
	}

	function shopx_in() {
		$this -> value = $this -> value != '' ? $this -> value : $this -> valuex;
		return $this -> value;
	}

	function shopx_out() {
		$info = '';
		if (is_numeric($this -> value)) {
			$this -> db -> select('shop_name');
			$q = $this -> db -> get_where('shop', array('shop_id' => $this -> value));
			if ($q -> num_rows() > 0) {
				$ls = $q -> row_array(0);
				$info = $ls['shop_name'];
			}
		}
		return $info;
	}

	function staffd() {
		//获取店铺
		$this -> db -> select('staff_name,staff_id');
		$q = $this -> db -> get_where('staff', array('identity_id' => '31'));
		$this -> value = $this -> value ? $this -> value : $this -> valuex;
		$info = '<select class="inputx" name="' . $this -> name . '" value="' . $this -> value . '">';
		$info .= '<option  value="0">-请选择-</option>';
		foreach ($q->result_array() as $v) {
			if ($v['staff_id'] == $this -> value) {
				$info .= '<option selected value="' . $v['staff_id'] . '">' . $v['staff_name'] . ' </option>';
			} else {
				$info .= '<option value="' . $v['staff_id'] . '">' . $v['staff_name'] . ' </option>';
			}
		}
		$info .= '</select>';
		return $info;
	}

	function staffd_in() {
		$this -> value = $this -> value != '' ? $this -> value : $this -> valuex;
		return $this -> value;
	}

	function staffd_out() {
		$info = '';
		if (is_numeric($this -> value)) {
			$this -> db -> select('staff_name');
			$q = $this -> db -> get_where('staff', array('staff_id' => $this -> value));
			if ($q -> num_rows() > 0) {
				$ls = $q -> row_array(0);
				$info = $ls['staff_name'];
			}
		}
		return $info;
	}

}
?>